from web.page.page import WebPage
import  time
from web.page.page_element import PageElement

from web.locator.locator import loginLocator

class LoginPage(WebPage):
    url = 'http://huicewang.com/ecshop/user.php'    #参数化--可以写在文件中的

    username = PageElement(**loginLocator.username_loc) #对象
    password = PageElement(**loginLocator.password_loc)
    submit = PageElement(**loginLocator.submit_loc)
    prompt = PageElement(**loginLocator.prompt_loc)
    exit = PageElement(**loginLocator.exit_loc)
    
    def login(self,username, password):
        self.username.send_keys(username)
        self.password.send_keys(password)
        self.submit.click()


if __name__ == '__main__':
    login = LoginPage()
    login.open()

    #成功登录
    login.login('huice001', 'huice001')

